package com.briup.day13;

import java.util.Scanner;

public class Test_String {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个手机号");
        String str = sc.nextLine();
        String str1 = str.substring(3,7);
        String str2 = str.replace(str1,"****");
        System.out.println(str2);
        System.out.println(str);
    }
    public static void main05(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个手机号");
        String s = sc.nextLine();
        String str=s.substring(0,3);//不包含3
        String str1=s.substring(7);
        System.out.println(str+"****"+str1);
    }
    public static void main04(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("input student msg: ");
// 001.zs.78
        String str = sc.nextLine();
//2.字符串拆分
//特殊含义的字符，作为分隔符，需要去除其特殊含义，下面两种方式
//String[] arr = str.split("\\.");
        String[] arr = str.split("\\.");
        System.out.println("id: " + arr[0]);
        System.out.println("name: " + arr[1]);
        int score = Integer.parseInt(arr[2]);
        System.out.println("score: " + score);
    }
    public static void main03(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名和密码");
        String username = sc.nextLine();
        String password = sc.nextLine();
        if("admin".equals(username) && "123456".equals(password)){
            System.out.println("登录成功");
        }else{
            System.out.println("登录失败");
        }
    }
    public static void main02(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入带有数字字符串");
        String str = sc.nextLine();
        //返回字符串个数
        System.out.println(str.length());
        //返回索引对应的char字符
        System.out.println(str.charAt(2));
        //把字符串拆分成字符数组返回
        char[] c1=str.toCharArray();
        System.out.println(c1);
        int count=0;
        for(char c:c1){
            if(c>='0'&&c<='9'){
                count++;
            }
        }
        System.out.println("数字字符串出现"+count+"次");
    }
    public static void main01(String[] args) {
        String s1=new String();
        System.out.println(s1);
        char[] c1={'a','b','c'};
        String s2=new String(c1);
        System.out.println(s2);
        String s3=new String("hello");
        System.out.println(s3);
        String s4="hello String";
        System.out.println(s4);
    }
}
